/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TerminerSejour.java
 *
 * Created on Jun 29, 2012, 9:31:58 PM
 */
package View;

import Controller.PaiementController;
import java.beans.PropertyChangeEvent;

/**
 *
 * @author fokasu
 */
public class PayerSejour extends AbstractViewPanel {
    PaiementController controller;
    
    /** Creates new form TerminerSejour */
    public PayerSejour(PaiementController paiementController) {
        this.controller = paiementController;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnPayer = new javax.swing.JButton();
        lblSousTotal = new javax.swing.JLabel();
        sousTotal = new javax.swing.JLabel();
        lblTPS = new javax.swing.JLabel();
        tps = new javax.swing.JLabel();
        lblTVQ = new javax.swing.JLabel();
        tvq = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        total = new javax.swing.JLabel();

        btnPayer.setText("Payer");
        btnPayer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnPayerMouseClicked(evt);
            }
        });

        lblSousTotal.setText("Sous-Total");

        sousTotal.setText("0.00$");

        lblTPS.setText("TPS");

        tps.setText("0.00$");

        lblTVQ.setText("TVQ");

        tvq.setText("0.00$");

        jLabel7.setText("Total");

        total.setText("0.00$");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel7)
                    .addComponent(lblTVQ)
                    .addComponent(lblTPS)
                    .addComponent(lblSousTotal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(total, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tvq, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tps, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addComponent(sousTotal)))
                .addContainerGap(16, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(45, Short.MAX_VALUE)
                .addComponent(btnPayer, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblSousTotal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblTPS)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblTVQ)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(sousTotal)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tps)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tvq)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(total)))
                .addGap(18, 18, 18)
                .addComponent(btnPayer)
                .addContainerGap(22, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnPayerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnPayerMouseClicked
        controller.addPaiement();
    }//GEN-LAST:event_btnPayerMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnPayer;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel lblSousTotal;
    private javax.swing.JLabel lblTPS;
    private javax.swing.JLabel lblTVQ;
    private javax.swing.JLabel sousTotal;
    private javax.swing.JLabel total;
    private javax.swing.JLabel tps;
    private javax.swing.JLabel tvq;
    // End of variables declaration//GEN-END:variables

    @Override
    public void modelPropertyChange(PropertyChangeEvent evt) {
        switch(evt.getPropertyName()){
            case PaiementController.SOUS_TOTAL_PROPERTY:
                sousTotal.setText(evt.getNewValue().toString());
                break;
            case PaiementController.TPS_PROPERTY:
                tps.setText(evt.getNewValue().toString());
                break;
            case PaiementController.TVQ_PROPERTY:
                tvq.setText(evt.getNewValue().toString());
                break;
            case PaiementController.TOTAL_PROPERTY:
                total.setText(evt.getNewValue().toString());
                break;
            case PaiementController.AJOUTER_PAIEMENT_EVENT:
                this.getTopLevelAncestor().setVisible(false);
                break;
        }
    }

    void updateAll() {
        controller.updateAll();
    }
}
